Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model Class Overwrite #134

Merged
merged 5 commits into from
Apr 2, 2024
Merged

Model Class Overwrite #134

merged 5 commits into from
Apr 2, 2024

Conversation

hafijul233
Copy link
Contributor

@hafijul233 hafijul233 commented Mar 20, 2024

WHY

I wanted to have more control over how settings are handled, not just the table name.

BEFORE - What was wrong? What was happening before this PR?

The Setting model that comes with package is called by setting crud controller and that was hardcoded.

AFTER - What is happening after this PR?

Now user will have more flexible options to change the model class that is called and modify or extend functionality as per project need.

HOW

How did you achieve that, in technical terms?

  1. Added a new configuration field named model.
  2. Changed value to controller setModel() method to configuration.
  3. On the SettingServiceprovider register method change alias value.

Is it a breaking change or non-breaking change?

Non-Breaking Change

How can we test the before & after?

Change the model field value on configuration file and output config values will be given model instances.

Adding an option so that users can overwrite the default model class to boot for setting.
Added the model value pulled from configuration insist of hard code.
Copy link

welcome bot commented Mar 20, 2024

BOOM! Your first PR with us, thank you so much! Someone will take a look at it shortly.

Please keep in mind that:

  • if this constitutes a breaking change, it might take quite a while for this to get merged; we try to emulate the Laravel release cycle as much as possible, so developers can upgrade both software once; this means a new big release every ~6 months;
  • even if it's a non-breaking change, it might take a few days/weeks for the PR to get merged; unless it's a no-brainer, we like to have some community feedback on new features, before we merge them; this leads to higher-quality code, in the end; we learnt this the hard way :-)
  • not all PRs get merged; sometimes we just have to hold out new features, to keep the packages lean; sometimes we don't include features that only apply to niche use cases;
  • we're not perfect; if you think we're wrong, call us out on it; but in a kind way :-) we all make mistakes, best we learn from them and build better software together;

Thank you!

--
Justin Case
The Backpack Robot

Now what user will set on config will reflect on service provider boot method also.
Co-authored-by: Pedro Martins <pxpm88@gmail.com>
@jcastroa87
Copy link
Member

Hi @hafijul233

Thanks a lot for this great feature, I test it, and it is working ok. I will ask @pxpm to make a final check.

Thanks again.

Cheers.

@hafijul233
Copy link
Contributor Author

@jcastroa87 I noticed that the setting model class alias it's also pointing to The Backpack Setting class. I will try testing that the Laravel alias loader can be configurable.

@hafijul233
Copy link
Contributor Author

I finalize my tweaks on the model class configurable option.

@pxpm pxpm mentioned this pull request Apr 2, 2024
@pxpm pxpm merged commit 51a76dc into Laravel-Backpack:main Apr 2, 2024
1 of 2 checks passed
Copy link

welcome bot commented Apr 2, 2024

WHOOP-WHOOP! Congrats, your first PR on this repo has officialy been merged.

party

If you want to help out the community in other ways, you can:

  • give your opinion on other Github Issues & PRs;
  • chat with others in the Gitter Chatroom (usually for quick help: How do I do X);
  • answer Backpack questions on Stackoverflow; you get points, people get help; you can subscribe to the backpack-for-laravel tag by adding a new filter; that will send you emails when new questions come up with our tag;

Again. Thank you for the PR. You are a wonderful person. Keep 'em coming :-)
Cheers!

--
Justin Case
The Backpack Robot

P.S. Help in the Backpack community is rewarded with free Backpack commercial licenses. It's the least we can do. If you feel you've helped the community with PRs, help & other stuff, please shoot Tabacitu an email and ask him if you qualify for free licenses. You scratch my back, I scratch your back. Thank you!

@pxpm
Copy link
Contributor

pxpm commented Apr 2, 2024

Thank you very much @hafijul233

Very clean and direct to the point, a maintainer dream of PR 🙏

Will be available on next version with a composer update.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants